The ASCII (American Standard Code for Information Interchange) value of a character is a numerical representation used to represent characters in computers.
def find_ascii_value(character):
return ord(character)
# Taking input for the character and finding its ASCII value
def find_and_display_ascii_value():
character = input("Enter a character: ")
ascii_value = find_ascii_value(character)
print("ASCII value of", character, "is:", ascii_value)
find_and_display_ascii_value()
Enter a character: A
ASCII value of A is: 65
Enter a character: !
ASCII value of ! is: 33
The function find_ascii_value(character)
finds the ASCII value of a character using the built-in ord()
function.
The function find_and_display_ascii_value()
takes input for the character, finds its ASCII value using the aforementioned function, and displays the result.